package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 故我
 * Date: 2023-05-08
 * Time: 14:20
 */

abstract class Animal {
    protected String name;

    public Animal() {

    }

    public Animal(String name) {
        this.name = name;
    }
}

//接口
interface IFly {
    void fly();
}

interface ISwin {
    default public void swin() {//默认是abstract
        System.out.println("游泳!");
    }
}

interface IRun {
    void run();
}

class Bird extends Animal implements IFly {

    public Bird(String name) {
        super(name);
    }

    @Override
    public void fly() {
        System.out.println("会飞!");
    }
}

class Fish extends Animal implements ISwin {

    public Fish(String name) {
        super(name);
    }

    @Override
    public void swin() {
        System.out.println("我会游泳!");
    }
}

class Frog extends Animal implements ISwin, IRun {

    @Override
    public void run() {
        System.out.println("我会跳!");
    }

    public void swin() {
        System.out.println("青蛙游泳!");
    }
}

class Robot implements IRun {

    @Override
    public void run() {
        System.out.println("机器人在跑步!");
    }
}

public class Testdemo1 {
    public static void walk(IRun irun) {
        irun.run();
    }

    public static void swin(ISwin iswin) {
        iswin.swin();
    }

    public static void main(String[] args) {
        walk(new Frog());
        swin(new Fish("七秒"));
        System.out.println("============");

        walk(new Robot());
    }
}
